package com.smart.village.big.screen.controller.bigscreen;

import com.smart.village.big.screen.domain.AjaxResult;
import com.smart.village.big.screen.service.BenefitPeopleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

/**
 * 数智惠农数据接口
 */
@Tag(name = "数智惠农数据接口")
@RestController
@RequestMapping("/benefit/people")
public class BenefitPeopleController {
    @Autowired
    private BenefitPeopleService benefitPeopleService;

    @Operation(summary = "村级事务-村民积分")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
    })
    @GetMapping("/getPersonalPointsAccountList")
    @ResponseBody
    public AjaxResult getPersonalPointsAccountList(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize
    ) {
        return AjaxResult.success(benefitPeopleService.getPersonalPointsAccountList(townNumber, villageNumber, pageNum, pageSize));
    }

    @Operation(summary = "村级事务-项目在线")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
    })
    @GetMapping("/getProjectProcessList")
    @ResponseBody
    public AjaxResult getProjectProcessList(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize
    ) {
        return AjaxResult.success(benefitPeopleService.getProjectProcessList(townNumber, villageNumber, pageNum, pageSize));
    }

    /**
     * 村级事务-政策宣传
     *
     * @return
     */
    @Operation(summary = "村级事务-政策宣传 ")
    @GetMapping("/getPolicyAdvocacy")
    @ResponseBody
    public AjaxResult getPolicyAdvocacy(
            @RequestParam String NewsTerminal,
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize
    ) {
        if (ObjectUtils.isEmpty(pageNum) || pageNum == 0) {
            pageNum = 1;
        }
        if (ObjectUtils.isEmpty(pageSize) || pageSize == 0) {
            pageSize = 10;
        }
        return AjaxResult.success(benefitPeopleService.getPolicyAdvocacy(pageNum, pageSize, NewsTerminal));
    }

    @Operation(summary = "惠民数据-三务公开")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
            @Parameter(name = "type", description = "类型 必传  0:党务公开 1:财务公开 2:村务公开"),
    })
    @GetMapping("/getThreeAffairsDisclosureList")
    @ResponseBody
    public AjaxResult getThreeAffairsDisclosureList(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false) String type,
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize
    ) {
        return AjaxResult.success(benefitPeopleService.getThreeAffairsDisclosureList(townNumber, villageNumber, type, pageNum, pageSize));
    }

    @Operation(summary = "惠民数据-三务公开-详情")
    @Parameters({
            @Parameter(name = "affairsSerialNumber", description = "三务公开ID 必传"),
    })
    @GetMapping("/getThreeAffairsDisclosureDetail")
    @ResponseBody
    public AjaxResult getThreeAffairsDisclosureDetail(
            @RequestParam String affairsSerialNumber
    ) {
        return AjaxResult.success(benefitPeopleService.getThreeAffairsDisclosureDetail(affairsSerialNumber));
    }

    @Operation(summary = "惠民数据-三资公开")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
    })
    @GetMapping("/getThreeResourceDisclosureList")
    @ResponseBody
    public AjaxResult getThreeResourceDisclosureList(
            @RequestParam @Parameter(description = "终端") String NewsTerminal,
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false) String category,
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize
    ) {
        return AjaxResult.success(benefitPeopleService.getThreeResourceDisclosureList(townNumber, villageNumber, category, pageNum, pageSize, NewsTerminal));
    }

    @Operation(summary = "惠民数据-村规村约")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
    })
    @GetMapping("/getVillageRegulationsAgreements")
    @ResponseBody
    public AjaxResult getVillageRegulationsAgreements(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber

    ) {
        return AjaxResult.success(benefitPeopleService.getVillageRegulationsAgreements(townNumber, villageNumber));
    }

    @Operation(summary = "惠民数据-村级通讯录")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
    })
    @GetMapping("/getVillageConcatPersonList")
    @ResponseBody
    public AjaxResult getVillageConcatPersonList(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber

    ) {
        return AjaxResult.success(benefitPeopleService.getVillageConcatPersonList(townNumber, villageNumber));
    }

    @Operation(summary = "村级事务-村级清单-列表")
    @Parameters({
            @Parameter(name = "listTypeSerialNumber", description = "清单类型ID"),
            @Parameter(name = "townNumber", description = "镇id"),
            @Parameter(name = "villageNumber", description = "村id"),
            @Parameter(name = "level", description = "级别 0 市级，1镇级，3村级"),


    })
    @GetMapping("/getListManagement")
    @ResponseBody
    public AjaxResult getListManagement(
            @RequestParam(required = false) String listTypeSerialNumber,
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(defaultValue = "2") String level,
            @RequestParam(required = false) String search,
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize
    ) {
        return AjaxResult.success(benefitPeopleService.getListManagement(listTypeSerialNumber, townNumber, villageNumber, level, search, pageNum, pageSize));
    }

    @Operation(summary = "村级事务-村级清单-详情")
    @Parameters({
            @Parameter(name = "listManagementSerialNumber", description = "清单ID"),

    })
    @GetMapping("/getListManagementDetail")
    @ResponseBody
    public AjaxResult getListManagementDetail(
            @RequestParam String listManagementSerialNumber
    ) {
        return AjaxResult.success(benefitPeopleService.getListManagementDetail(listManagementSerialNumber));
    }

    @Operation(summary = "惠民数据-志愿活动")
    @Parameters({
            @Parameter(name = "townNumber", description = "镇编码 必传"),
            @Parameter(name = "villageNumber", description = "村编码 必传"),
    })
    @GetMapping("/getVolunteerActivityList")
    @ResponseBody
    public AjaxResult getVolunteerActivityList(
            @RequestParam(required = false) String townNumber,
            @RequestParam(required = false) String villageNumber,
            @RequestParam(required = false, defaultValue = "1") @Parameter(description = "当前页数") int pageNum,
            @RequestParam(required = false, defaultValue = "10") @Parameter(description = "每页条数") int pageSize
    ) {
        return AjaxResult.success(benefitPeopleService.getVolunteerActivityList(townNumber, villageNumber, pageNum, pageSize));
    }
}
